﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 实验报告2._2
{
    class Program
    {
        static void Main(string[] args)
        {
            Vehicle v1 = new Car(30,10);
            Vehicle v2 = new Truck(30,20);
            v1.Run(1000);
            v2.Run(1000);
            Console.ReadKey();
        }
    }
    public abstract class Vehicle
    {
        public float V { get; set; }
        public Vehicle(float v)
        {
            V = v;
        }
        public virtual void Run(float d)
        {
            Console.WriteLine("行驶{0}公里用时{1}",d,d/ V);
        }
    }
    public class Car:Vehicle
    {
        public int Passengers { get; set; }
        public Car(float v,int p):base (v)
        {
            Passengers = p;
        }
    }
    public class Truck:Vehicle
    {
        public float Load { get ; set; }
        public Truck(float v,float l):base (v)
        {
            Load = l;
        }
        public override void Run(float d)
        {
            Console.WriteLine("卡车行驶{0}公里用时{1}", d, (1+Load/100)*d / V);
        }
    }
}